package com.ruoyi.supermarket.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.supermarket.domain.Vo.ShCPay;
import com.ruoyi.supermarket.domain.Vo.ShXPay;
import com.ruoyi.supermarket.domain.Yfpay;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.supermarket.domain.Yspay;
import com.ruoyi.supermarket.service.IYspayService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 应收汇总Controller
 * 
 * @author ruoyi
 * @date 2024-05-30
 */
@RestController
@RequestMapping("/supermarket/yspay")
public class YspayController extends BaseController
{
    @Autowired
    private IYspayService yspayService;

    /**
     * 查询应收汇总列表
     */
    @PreAuthorize("@ss.hasPermi('supermarket:yspay:list')")
    @GetMapping("/list")
    public TableDataInfo list(Yspay yspay)
    {
        startPage();
        List<Yspay> list = yspayService.selectYspayList(yspay);
        return getDataTable(list);
    }
/**
 * 查询应收汇总列表
 */
    @PreAuthorize("@ss.hasPermi('supermarket:yspay:list')")
    @GetMapping("/listFzd")
    public TableDataInfo listFzd(Yspay yspay)
    {
        startPage();
        List<Yspay> list = yspayService.selectYspayListFzd(yspay);
        return getDataTable(list);
    }
    /**
     * 导出应收汇总列表
     */
    @PreAuthorize("@ss.hasPermi('supermarket:yspay:export')")
    @Log(title = "应收汇总", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Yspay yspay)
    {
        List<Yspay> list = yspayService.selectYspayList(yspay);
        ExcelUtil<Yspay> util = new ExcelUtil<Yspay>(Yspay.class);
        util.exportExcel(response, list, "应收汇总数据");
    }

    /**
     * 获取应收汇总详细信息
     */
    @PreAuthorize("@ss.hasPermi('supermarket:yspay:query')")
    @GetMapping(value = "/{yspayId}")
    public AjaxResult getInfo(@PathVariable("yspayId") Long yspayId)
    {
        return success(yspayService.selectYspayByYspayId(yspayId));
    }

    /**
     * 新增应收汇总
     */
    @PreAuthorize("@ss.hasPermi('supermarket:yspay:add')")
    @Log(title = "应收汇总", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Yspay yspay)
    {
        return toAjax(yspayService.insertYspay(yspay));
    }

    /**
     * 修改应收汇总
     */
    @PreAuthorize("@ss.hasPermi('supermarket:yspay:edit')")
    @Log(title = "应收汇总", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Yspay yspay)
    {
        return toAjax(yspayService.updateYspay(yspay));
    }

    /**
     * 删除应收汇总
     */
    @PreAuthorize("@ss.hasPermi('supermarket:yspay:remove')")
    @Log(title = "应收汇总", businessType = BusinessType.DELETE)
	@DeleteMapping("/{yspayIds}")
    public AjaxResult remove(@PathVariable Long[] yspayIds)
    {
        return toAjax(yspayService.deleteYspayByYspayIds(yspayIds));
    }


    //审核
    @PostMapping("/audit")
    @PreAuthorize("@ss.hasPermi('supermarket:yspay:audit')")
    public AjaxResult audit(@RequestBody ShXPay shxPay)
    {
        return yspayService.audit(shxPay);
    }

    //核销
    @PostMapping("/hxPay")
    @PreAuthorize("@ss.hasPermi('supermarket:yspay:hxPay')")
    public AjaxResult hxPay(@RequestBody Yspay yspay)
    {
        return yspayService.hxPay(yspay);
    }


    @PostMapping("/Fzd")
    @PreAuthorize("@ss.hasPermi('supermarket:yspay:Fzd')")
public AjaxResult fzd(@RequestBody Yspay yspay)
{
    return yspayService.fzd(yspay);
}

    @GetMapping("/Fsh/{yspayId}")
    @PreAuthorize("@ss.hasPermi('supermarket:yspay:fsh')")
    public AjaxResult fsh(@PathVariable Long yspayId)
    {
        return yspayService.fsh(yspayId);
    }


}
